package net.stogi.common.gwt.frame.client.module;


/**
 * Interface for module factories register. Covers basic operations on register.
 * 
 * @author Michał Stogowski
 */
public interface ModuleFactoryRegistry {

	/**
	 * Clears all registered module factories from the register.
	 */
	void clearHandlers();

	/**
	 * Searches the register and returns the {@link ModuleFactory} of given
	 * {@link Module}, or <code>null</code> if none is available.
	 * 
	 * @param <M>
	 *            {@link Module} type
	 * @param clazz
	 *            {@link Module} class
	 * @return {@link ModuleFactory} which handle creation of module with given
	 *         class
	 */
	<M extends Module> ModuleFactory<M> findFactory(Class<M> clazz);

	/**
	 * Adds {@link ModuleFactory} to register that handles creation of given
	 * {@link Module} class.
	 * 
	 * @param <M>
	 *            {@link Module} type
	 * @param clazz
	 *            {@link Module} class
	 * @param factory
	 *            {@link ModuleFactory} added to register
	 */
	<M extends Module> void registerFactory(Class<M> clazz, ModuleFactory<M> factory);

	/**
	 * Removes {@link ModuleFactory} from register that handles creation of
	 * given {@link Module} class.
	 * 
	 * @param <M>
	 *            {@link Module} type
	 * @param clazz
	 *            {@link Module} class
	 */
	<M extends Module> void unregisterFactory(Class<M> clazz);
}
